<template>
<!--  <div style="margin-top: 40px" id="but_sc">-->
    <!--    <input type="file" name="fileSelect" id="fileSelect" class="fileSelect"/>-->
    <!--    <p class="uploadFile">-->
    <!--      <button @click="fileupload">文件上传</button>-->
    <!--    </p>-->
<!--  </div>-->
  <uploader :options="options" class="uploader-example" :file-status-text="statusText" @file-success="fileSuccess">
    <uploader-unsupport></uploader-unsupport>
    <uploader-drop>
      <p> 请选择你要上传的文件 </p>
      <uploader-btn :attrs="attrs">select PDF files</uploader-btn>
    </uploader-drop>
    <uploader-list></uploader-list>
  </uploader>
</template>

<script>


  export default {
    name: 'fileup',
    data () {
      return {
        options: {
          // 可通过 https://github.com/simple-uploader/Uploader/tree/develop/samples/Node.js 示例启动服务
          target: '/pdfapi/save',
          testChunks: false,
          prioritizeFirstAndLastChunk:true,
          chunkSize:2048*1024*1024
        },
        attrs: {
          accept: 'application/pdf'
        },
        statusText:{
          success: '成功了',
          error: '出错了',
          uploading: '上传中',
          paused: '暂停中',
          waiting: '等待中'
        },
        result:''

      }
    },
    methods: {
      fileSuccess (rootFile, file, message, chunk) {
        console.log('complete', message)
        this.result = JSON.parse(message)
        if (this.result.result_code != "0000") {
          this.statusText.success = this.result.message
        }
      }
    }

  }
</script>
<style scoped>
  .uploader-example {
    width: auto;
    padding: 15px;
    margin: 40px auto 0;
    font-size: 12px;
    box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  }
  .uploader-example .uploader-btn {
    margin-right: 4px;
  }
  .uploader-example .uploader-list {
    max-height: 440px;
    overflow: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
</style>



